<html>
<head><meta charset="utf-8"><title>intrinsics / uninitialized · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html">intrinsics / uninitialized</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169717970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169717970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169717970">(Jul 05 2019 at 15:39)</a>:</h4>
<p>So I'm looking at <a href="https://github.com/rust-lang/rust/issues/62397" target="_blank" title="https://github.com/rust-lang/rust/issues/62397">https://github.com/rust-lang/rust/issues/62397</a></p>



<a name="169717983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169717983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169717983">(Jul 05 2019 at 15:39)</a>:</h4>
<p>I believe the only remaining use of <code>uninitialized</code> in the SGX target is this:</p>
<div class="codehilite"><pre><span></span>fn rdrand64() -&gt; u64 {
    unsafe {
        let mut ret: u64 = crate::mem::uninitialized();
        for _ in 0..10 {
            if crate::arch::x86_64::_rdrand64_step(&amp;mut ret) == 1 {
                return ret;
            }
        }
        rtabort!(&quot;Failed to obtain random data&quot;);
    }
}
</pre></div>



<a name="169718051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718051">(Jul 05 2019 at 15:40)</a>:</h4>
<p>now this is interesting because if I understand correctly, just having a <code>&amp;mut</code> to uninitialized memory is UB</p>



<a name="169718059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718059">(Jul 05 2019 at 15:40)</a>:</h4>
<p>but the intrinsic requires a <code>&amp;mut</code></p>



<a name="169718060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718060">(Jul 05 2019 at 15:40)</a>:</h4>
<blockquote>
<p>just having a &amp;mut to uninitialized memory is UB</p>
</blockquote>
<p>correct</p>



<a name="169718062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718062">(Jul 05 2019 at 15:40)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <span class="user-mention" data-user-id="132920">@gnzlbg</span></p>



<a name="169718085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718085">(Jul 05 2019 at 15:41)</a>:</h4>
<div class="codehilite"><pre><span></span>src/libstd/sys/sgx/mutex.rs
71:    pub const fn uninitialized() -&gt; ReentrantMutex {

src/libstd/sys/sgx/mod.rs
145:            let mut ret: u64 = crate::mem::uninitialized();

src/libstd/sys/sgx/abi/usercalls/mod.rs
19:        let mut userbuf = alloc::User::&lt;[u8]&gt;::uninitialized(total_len);
55:        let mut userbuf = alloc::User::&lt;[u8]&gt;::uninitialized(total_len);
92:        let mut local = alloc::User::&lt;ByteBuffer&gt;::uninitialized();
107:        let mut bufs = alloc::User::&lt;[ByteBuffer; 2]&gt;::uninitialized();
127:        let mut bufs = alloc::User::&lt;[ByteBuffer; 2]&gt;::uninitialized();

src/libstd/sys/sgx/abi/usercalls/alloc.rs
187:    // This function returns memory that is practically uninitialized, but is
249:    pub fn uninitialized() -&gt; Self {
257:    pub fn uninitialized(n: usize) -&gt; Self {
</pre></div>



<a name="169718091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718091">(Jul 05 2019 at 15:41)</a>:</h4>
<blockquote>
<p>correct</p>
</blockquote>
<p>not necessarily</p>



<a name="169718097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718097">(Jul 05 2019 at 15:41)</a>:</h4>
<p>It hasn't been decided yet.</p>



<a name="169718109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718109">(Jul 05 2019 at 15:41)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span>  it is UB <em>until decided otherwise</em>.</p>



<a name="169718123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718123">(Jul 05 2019 at 15:42)</a>:</h4>
<p>or "unspecified"; in any case it means "don't do it".</p>



<a name="169718184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718184">(Jul 05 2019 at 15:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> only one of those is <code>std::mem::uninitialized</code></p>



<a name="169718194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718194">(Jul 05 2019 at 15:42)</a>:</h4>
<p>Yeah, looking at it the other bits are "interesting" and I want to know more but I don't have the time right now :)</p>



<a name="169718203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718203">(Jul 05 2019 at 15:43)</a>:</h4>
<p>I don't know if churning from u64 to MaybeUninit&lt;u64&gt; is worth it until its decided</p>



<a name="169718293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718293">(Jul 05 2019 at 15:44)</a>:</h4>
<p>like in <span class="user-mention" data-user-id="138938">@Jethro</span> they are creating a reference and coercing it to a raw pointer directly</p>



<a name="169718317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718317">(Jul 05 2019 at 15:44)</a>:</h4>
<p>so depending on what happens with <code>&amp;raw</code>, their code might not be creating a reference at all</p>



<a name="169718319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718319">(Jul 05 2019 at 15:44)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> ah but am I? because as I said the intrinsic takes a <code>&amp;mut</code>, not a <code>*mut</code></p>



<a name="169718334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718334">(Jul 05 2019 at 15:44)</a>:</h4>
<p>that intrinsic takes a &amp;mut ?</p>



<a name="169718341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718341">(Jul 05 2019 at 15:44)</a>:</h4>
<p><a href="https://doc.rust-lang.org/core/arch/x86_64/fn._rdrand64_step.html" target="_blank" title="https://doc.rust-lang.org/core/arch/x86_64/fn._rdrand64_step.html">https://doc.rust-lang.org/core/arch/x86_64/fn._rdrand64_step.html</a></p>



<a name="169718352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718352">(Jul 05 2019 at 15:45)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/src/core/up/stdsimd/crates/core_arch/src/x86_64/rdrand.rs.html#26-30" target="_blank" title="https://doc.rust-lang.org/nightly/src/core/up/stdsimd/crates/core_arch/src/x86_64/rdrand.rs.html#26-30">https://doc.rust-lang.org/nightly/src/core/up/stdsimd/crates/core_arch/src/x86_64/rdrand.rs.html#26-30</a></p>



<a name="169718363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718363">(Jul 05 2019 at 15:45)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">_rdrand64_step</span><span class="p">(</span><span class="n">val</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="kt">u64</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">i32</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">v</span><span class="p">,</span><span class="w"> </span><span class="n">flag</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x86_rdrand64_step</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="o">*</span><span class="n">val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">v</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">flag</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="169718375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718375">(Jul 05 2019 at 15:45)</a>:</h4>
<p>yup, you are right</p>



<a name="169718428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718428">(Jul 05 2019 at 15:46)</a>:</h4>
<p>so the question is whether the reference is invalid, which depends on whether the u64 is invalid, which we don't know</p>



<a name="169718442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718442">(Jul 05 2019 at 15:46)</a>:</h4>
<p>the reference is dereferenceable, aligned, noalias, etc.</p>



<a name="169718453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718453">(Jul 05 2019 at 15:46)</a>:</h4>
<p><span class="user-mention" data-user-id="138938">@Jethro</span> would there be any problem with doing <code>let mut ret: u64 = 0;</code> ?</p>



<a name="169718455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718455">(Jul 05 2019 at 15:46)</a>:</h4>
<p>independently of whether the u64 is uninitialized or not, so all of that is ok from LLVM's pov</p>



<a name="169718465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718465">(Jul 05 2019 at 15:47)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> not really, you're just relying on the optimizer to get rid of it then</p>



<a name="169718471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718471">(Jul 05 2019 at 15:47)</a>:</h4>
<p>that's what I'd do then</p>



<a name="169718577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718577">(Jul 05 2019 at 15:49)</a>:</h4>
<p>and possibly change the signature of that intrinsic to take a raw pointer if feasible</p>



<a name="169718646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718646">(Jul 05 2019 at 15:50)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span>  Why doesn't <code>_rdrand64_step</code> just return <code>-&gt; (u64, i32)</code>?</p>



<a name="169718662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718662">(Jul 05 2019 at 15:50)</a>:</h4>
<p>because C doesn't have multiple return arguments</p>



<a name="169718666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718666">(Jul 05 2019 at 15:50)</a>:</h4>
<p>because it needs to match the Intel-defined intrinsic</p>



<a name="169718668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718668">(Jul 05 2019 at 15:50)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> because it follows the C signature.</p>



<a name="169718717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718717">(Jul 05 2019 at 15:51)</a>:</h4>
<p>but this function is to be called from Rust, not C... so why do we need to follow C's poor design here?</p>



<a name="169718769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718769">(Jul 05 2019 at 15:52)</a>:</h4>
<p>Because you didn't offered to write an RFC designing 10k intrinsics, with rationale for each, etc.</p>



<a name="169718775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718775">(Jul 05 2019 at 15:52)</a>:</h4>
<p>;)</p>



<a name="169718779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718779">(Jul 05 2019 at 15:52)</a>:</h4>
<p>all arch intrinsics match C</p>



<a name="169718789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718789">(Jul 05 2019 at 15:52)</a>:</h4>
<p>I know they do; but to me this feels like "reasons"</p>



<a name="169718801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718801">(Jul 05 2019 at 15:52)</a>:</h4>
<p>the only reason is the one i mentioned, 10k intrinsics</p>



<a name="169718813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718813">(Jul 05 2019 at 15:53)</a>:</h4>
<p>proposing an API for a single std lib function takes months, do the math</p>



<a name="169718824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718824">(Jul 05 2019 at 15:53)</a>:</h4>
<p>I think over time we can definitely expose APIs over them that are better for widely used functions</p>



<a name="169718829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718829">(Jul 05 2019 at 15:53)</a>:</h4>
<p>it was either do them the Rust way, and never have any intrinsics, or shipping what C does, two years ago</p>



<a name="169718830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718830">(Jul 05 2019 at 15:53)</a>:</h4>
<p>(and there may already be work doing that, not sure)</p>



<a name="169718835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718835">(Jul 05 2019 at 15:53)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span>  but the code for this intrinsic was not machine generated?</p>



<a name="169718839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718839">(Jul 05 2019 at 15:53)</a>:</h4>
<p>the signature is machine-verified to match the C version</p>



<a name="169718880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718880">(Jul 05 2019 at 15:54)</a>:</h4>
<p>none of them are</p>



<a name="169718891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718891">(Jul 05 2019 at 15:54)</a>:</h4>
<p>too many corner cases for machine generation</p>



<a name="169718903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718903">(Jul 05 2019 at 15:54)</a>:</h4>
<p>we used to do that, it didn't work</p>



<a name="169718912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718912">(Jul 05 2019 at 15:54)</a>:</h4>
<p>aha; seems strange for <code>&amp;mut</code> to be acceptable in the eyes of the machine verifier</p>



<a name="169718928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718928">(Jul 05 2019 at 15:55)</a>:</h4>
<p>anyway, the C version here uses a pointer (obviously)</p>



<a name="169718932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718932">(Jul 05 2019 at 15:55)</a>:</h4>
<p>its accepted on FFI where pointers are</p>



<a name="169718938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718938">(Jul 05 2019 at 15:55)</a>:</h4>
<p>its ABi compatible with C</p>



<a name="169718939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718939">(Jul 05 2019 at 15:55)</a>:</h4>
<p>so I agree it seems strange that this takes a reference</p>



<a name="169718950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718950">(Jul 05 2019 at 15:55)</a>:</h4>
<p>a pointer can be null, a reference can't</p>



<a name="169718961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718961">(Jul 05 2019 at 15:55)</a>:</h4>
<p>you can't pass this API a null pointer</p>



<a name="169718986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169718986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169718986">(Jul 05 2019 at 15:55)</a>:</h4>
<p>Maybe we didn't have <code>NonNull&lt;T&gt;</code> back then</p>



<a name="169719045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719045">(Jul 05 2019 at 15:56)</a>:</h4>
<p>AFAICT, &amp;mut u64 is ok even if u64 is uninitialized</p>



<a name="169719046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719046">(Jul 05 2019 at 15:56)</a>:</h4>
<p>captain hindsight: should MaybeUninit::as_mut_ptr have returned NonNull&lt;T&gt;?</p>



<a name="169719081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719081">(Jul 05 2019 at 15:57)</a>:</h4>
<p>that's another wrapper you need to unwrap, what's the win ?</p>



<a name="169719085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719085">(Jul 05 2019 at 15:57)</a>:</h4>
<p>you can always put it in a NonNull&lt;T&gt; yourself, if you need to store it somewhere where you need a niche</p>



<a name="169719145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719145">(Jul 05 2019 at 15:58)</a>:</h4>
<p>well say the rdrand intrinsic would've taken NonNull&lt;u64&gt;, then you have to jump through hoops to call it on uninitialized memory</p>



<a name="169719149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719149">(Jul 05 2019 at 15:58)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> not if references require that the referent is allocated and valid?</p>



<a name="169719160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719160">(Jul 05 2019 at 15:59)</a>:</h4>
<p>even if referefent is allocated and valid</p>



<a name="169719167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719167">(Jul 05 2019 at 15:59)</a>:</h4>
<p>unwrapping NonNull is easy, creating one is "hard"</p>



<a name="169719168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719168">(Jul 05 2019 at 15:59)</a>:</h4>
<p>depends on what it means for u64 to be valid</p>



<a name="169719184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719184">(Jul 05 2019 at 15:59)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> so you are assuming instead that integers may be uninit?</p>



<a name="169719246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719246">(Jul 05 2019 at 16:00)</a>:</h4>
<p>its an assumption a lot of code, like the above, relies on</p>



<a name="169719252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719252">(Jul 05 2019 at 16:00)</a>:</h4>
<p>otherwise all that code would be UB</p>



<a name="169719259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719259">(Jul 05 2019 at 16:00)</a>:</h4>
<p>we could do that, but nobody has managed to find a good argument for doing that</p>



<a name="169719270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719270">(Jul 05 2019 at 16:00)</a>:</h4>
<p>we don't gain any optmization potential from doing so</p>



<a name="169719281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719281">(Jul 05 2019 at 16:01)</a>:</h4>
<p>and we don't get any better tools for checking UB</p>



<a name="169719300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719300">(Jul 05 2019 at 16:01)</a>:</h4>
<p><span class="user-mention" data-user-id="138938">@Jethro</span> I have confirmed that <code>tmp = 0</code> has no negative effect on generated code.</p>



<a name="169719370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169719370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169719370">(Jul 05 2019 at 16:02)</a>:</h4>
<p>Even at opt-level=0</p>



<a name="169725424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725424">(Jul 05 2019 at 17:53)</a>:</h4>
<blockquote>
<p>we could do that, but nobody has managed to find a good argument for doing that</p>
</blockquote>
<p>wait, wasn't it you who <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/71#issuecomment-460632499" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/71#issuecomment-460632499">argued *against* uninitialized integers</a>...?</p>



<a name="169725427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725427">(Jul 05 2019 at 17:53)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I am very surprised to see you on <em>that</em> side of the fence now^^</p>



<a name="169725442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725442">(Jul 05 2019 at 17:53)</a>:</h4>
<p>also notice that for the SGX snippet above, the reference question is irrelevant. it starts by creating an uninitialized integer. if that's okay by-value, it's certainly okay by-ref.</p>



<a name="169725505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725505">(Jul 05 2019 at 17:54)</a>:</h4>
<p>but indeed I am irritated by the use of <code>&amp;mut</code> as an out-pointer here</p>



<a name="169725532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725532">(Jul 05 2019 at 17:55)</a>:</h4>
<blockquote>
<p>also notice that for the SGX snippet above, the reference question is irrelevant. it starts by creating an uninitialized integer. if that's okay by-value, it's certainly okay by-ref.</p>
</blockquote>
<p>but it doesn't need to be by value</p>



<a name="169725543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725543">(Jul 05 2019 at 17:55)</a>:</h4>
<p>generally in Rust <code>fn(x: &amp;mut T)</code> is basically the same as <code>fn(x: T) -&gt; T</code> but more efficient -- in-place modification instead of pass-through. So from that perspective, the intrinsic definitely should take a raw pointer.</p>



<a name="169725544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725544">(Jul 05 2019 at 17:55)</a>:</h4>
<p>I can use MaybeUninit</p>



<a name="169725549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725549">(Jul 05 2019 at 17:55)</a>:</h4>
<p>but not without creating a ref</p>



<a name="169725550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725550">(Jul 05 2019 at 17:55)</a>:</h4>
<blockquote>
<p>I can use MaybeUninit</p>
</blockquote>
<p>sure</p>



<a name="169725599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725599">(Jul 05 2019 at 17:56)</a>:</h4>
<blockquote>
<p>but not without creating a ref</p>
</blockquote>
<p>because of the type of the intrinsic. gotcha.<br>
I thought you were discussing the original code. if unintiialized integers are okay, that code is okay.</p>



<a name="169725609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725609">(Jul 05 2019 at 17:56)</a>:</h4>
<p>no that's not my issue</p>



<a name="169725617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169725617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jethro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169725617">(Jul 05 2019 at 17:56)</a>:</h4>
<p>someone else in this thread might have been discussing that issue, but not me ;)</p>



<a name="169740425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740425">(Jul 05 2019 at 23:00)</a>:</h4>
<blockquote>
<p>generally in Rust fn(x: &amp;mut T) is basically the same as fn(x: T) -&gt; T but more efficient -- in-place modification instead of pass-through. So from that perspective, the intrinsic definitely should take a raw pointer.</p>
</blockquote>
<p>in general it isn't more efficient - LLVM is better at optimizing values, than pointer accesses across functions</p>



<a name="169740440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740440">(Jul 05 2019 at 23:01)</a>:</h4>
<p>in rust just always prefer fn(T) -&gt; T over fn(&amp;mut T)</p>



<a name="169740452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740452">(Jul 05 2019 at 23:01)</a>:</h4>
<p>its not only simpler,  it helps with optimizations</p>



<a name="169740462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740462">(Jul 05 2019 at 23:01)</a>:</h4>
<p>(and readability often, IMO)</p>



<a name="169740464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740464">(Jul 05 2019 at 23:01)</a>:</h4>
<p>for the intrinsics, being able to use them to initialize invalid memory might have been useful when they were introduced to C in the early 90s</p>



<a name="169740509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740509">(Jul 05 2019 at 23:02)</a>:</h4>
<p>right now, it kind of doesn't really matter, LLVM lowers it all to the same thing</p>



<a name="169740517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740517">(Jul 05 2019 at 23:02)</a>:</h4>
<p>if the intrinsic can't be used to initialize invalid memory, then we'd need to change its signature</p>



<a name="169740534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740534">(Jul 05 2019 at 23:03)</a>:</h4>
<p>ideally we'd like something in between pointer and reference</p>



<a name="169740577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/169740577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#169740577">(Jul 05 2019 at 23:04)</a>:</h4>
<p>not requiring validity, but guaranteeing alignment, and dereferenceable</p>



<a name="170643508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170643508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170643508">(Jul 11 2019 at 15:23)</a>:</h4>
<blockquote>
<p>(and readability often, IMO)</p>
</blockquote>
<p>so you are saying a version of <code>push</code> that passes ownership through would be mroe readable? or is that one of the exceptions?</p>



<a name="170643535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170643535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170643535">(Jul 11 2019 at 15:23)</a>:</h4>
<p>I would actually say that <code>&amp;mut T</code> is frequently a more readable version of <code>T -&gt; T</code> ;)</p>



<a name="170643622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170643622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170643622">(Jul 11 2019 at 15:24)</a>:</h4>
<p>hm, you mean <code>Vec::push</code> being defined as <code>Vec::push(Self, T) -&gt; Self</code> basically?</p>



<a name="170644531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170644531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170644531">(Jul 11 2019 at 15:34)</a>:</h4>
<p>that's what you basically said is more readable</p>



<a name="170644546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170644546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170644546">(Jul 11 2019 at 15:34)</a>:</h4>
<p><code>fn(T) -&gt; T</code> instead of <code>fn(&amp;mut T)</code></p>



<a name="170644665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170644665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170644665">(Jul 11 2019 at 15:36)</a>:</h4>
<p>hm, so I disagree a little</p>



<a name="170644731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170644731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170644731">(Jul 11 2019 at 15:37)</a>:</h4>
<p>I guess it depends</p>



<a name="170645007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170645007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170645007">(Jul 11 2019 at 15:39)</a>:</h4>
<p>you disagree with yourself? ;)<br>
Or you disagree with my statement that this is a consequence of your statement?</p>



<a name="170645073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170645073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170645073">(Jul 11 2019 at 15:40)</a>:</h4>
<p>I don't know about readable, but having a <code>&amp;mut</code> to a value is more common than ownership</p>



<a name="170645150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170645150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170645150">(Jul 11 2019 at 15:41)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I think I sort of feel that it's different -- <code>fn(A, B) -&gt; A</code> vs. <code>fn(&amp;mut A, B)</code> and <code>fn(A) -&gt; A</code> vs. <code>fn(&amp;mut A)</code></p>



<a name="170645230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170645230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170645230">(Jul 11 2019 at 15:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> interesting</p>



<a name="170646434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646434">(Jul 11 2019 at 15:57)</a>:</h4>
<p>I do feel <code>vec.push(0).push(1)</code> is more readable personally</p>



<a name="170646510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646510">(Jul 11 2019 at 15:58)</a>:</h4>
<p>I really fancy the fluent APIs; sadly <code>push</code> doesn't return <code>&amp;mut Self</code></p>



<a name="170646513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646513">(Jul 11 2019 at 15:58)</a>:</h4>
<p>I think things change when you "builder" pattern (not quite the right name)</p>



<a name="170646537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646537">(Jul 11 2019 at 15:58)</a>:</h4>
<p>The session types idiom is particularly nice</p>



<a name="170646599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646599">(Jul 11 2019 at 15:59)</a>:</h4>
<p>sure -- &amp;mut T is in some sense less powerful in that way</p>



<a name="170646607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646607">(Jul 11 2019 at 15:59)</a>:</h4>
<p>well, for some T anyway</p>



<a name="170646680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646680">(Jul 11 2019 at 16:00)</a>:</h4>
<p>I guess A -&gt; A is equivalent but A&lt;T&gt; -&gt; A&lt;U&gt; feels where T, U are zero-sized session types feels very similar</p>



<a name="170646695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/intrinsics%20/%20uninitialized/near/170646695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/intrinsics.20.2F.20uninitialized.html#170646695">(Jul 11 2019 at 16:00)</a>:</h4>
<p>(though very different from a type perspective)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>